package com.tudouji.project.arealand.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.arealand.domain.Plantmanager;
import com.tudouji.project.arealand.service.IPlantmanagerService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 种植户/基地经理关联Controller
 * 
 * @author tudouji
 * @date 2023-03-15
 */
@RestController
@RequestMapping("/manager/plantmanager")
public class PlantmanagerController extends BaseController
{
    @Autowired
    private IPlantmanagerService plantmanagerService;

    /**
     * 查询种植户/基地经理关联列表
     */
    @PreAuthorize("@ss.hasPermi('manager:plantmanager:list')")
    @GetMapping("/list")
    public TableDataInfo list(Plantmanager plantmanager)
    {
        startPage();
        List<Plantmanager> list = plantmanagerService.selectPlantmanagerList(plantmanager);
        return getDataTable(list);
    }

    /**
     * 导出种植户/基地经理关联列表
     */
    @PreAuthorize("@ss.hasPermi('manager:plantmanager:export')")
    @Log(title = "种植户/基地经理关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Plantmanager plantmanager)
    {
        List<Plantmanager> list = plantmanagerService.selectPlantmanagerList(plantmanager);
        ExcelUtil<Plantmanager> util = new ExcelUtil<Plantmanager>(Plantmanager.class);
        return util.exportExcel(list, "plantmanager");
    }

    /**
     * 获取种植户/基地经理关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('manager:plantmanager:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(plantmanagerService.selectPlantmanagerById(guid));
    }

    /**
     * 新增种植户/基地经理关联
     */
    @PreAuthorize("@ss.hasPermi('manager:plantmanager:add')")
    @Log(title = "种植户/基地经理关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Plantmanager plantmanager)
    {
        return toAjax(plantmanagerService.insertPlantmanager(plantmanager));
    }

    /**
     * 修改种植户/基地经理关联
     */
    @PreAuthorize("@ss.hasPermi('manager:plantmanager:edit')")
    @Log(title = "种植户/基地经理关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Plantmanager plantmanager)
    {
        return toAjax(plantmanagerService.updatePlantmanager(plantmanager));
    }

    /**
     * 删除种植户/基地经理关联
     */
    @PreAuthorize("@ss.hasPermi('manager:plantmanager:remove')")
    @Log(title = "种植户/基地经理关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(plantmanagerService.deletePlantmanagerByIds(guids));
    }
}
